public class 区域和检索_数组不可变 {
    public static int[] arr;
    public void NumArray(int[] nums) {
        int n = nums.length;
        arr = new int[n + 1];
        // 前缀和
        for (int i = 1; i <= n; i++) {
            arr[i] = nums[i - 1] + arr[i - 1];
        }

    }

    public int sumRange(int left, int right) {
        // 下标对应
        return arr[right + 1] - arr[left];
    }
}
